
<!DOCTYPE html>
<html lang="zh-cn">
    
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="generator" content="ML3426&#39;s Lair">
    <title>Java9 Modularity - Chapter 2 笔记-模块和模块化JDK - ML3426&#39;s Lair</title>
    <meta name="author" content="ML3426">
    
    
    
    <script type="application/ld+json">{"@context":"http://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"ML3426","sameAs":["https://github.com/ML3426","https://weibo.com/ML3426"],"image":"http://oin1tuauu.bkt.clouddn.com/avatar.jpg"},"articleBody":"如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。\n模块化和模块化JDK图中还显示了这些平台模块的自己以及依赖关系，这些边显示了模块之间的单项依赖关系。并且Java的模块系统不允许模块之间存在编译时循环依赖，因此图中所有箭头都是朝下的，没有循环。通过运行java --list-modules可以获取平台模块的完整列表，在我的机器（Java 10.0.1）上运行的结果为：123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899ml3426@ML3426: java --list-modulesjava.activation@10.0.1java.base@10.0.1java.compiler@10.0.1java.corba@10.0.1java.datatransfer@10.0.1java.desktop@10.0.1java.instrument@10.0.1java.jnlp@10.0.1java.logging@10.0.1java.management@10.0.1java.management.rmi@10.0.1java.naming@10.0.1java.prefs@10.0.1java.rmi@10.0.1java.scripting@10.0.1java.se@10.0.1java.se.ee@10.0.1java.security.jgss@10.0.1java.security.sasl@10.0.1java.smartcardio@10.0.1java.sql@10.0.1java.sql.rowset@10.0.1java.transaction@10.0.1java.xml@10.0.1java.xml.bind@10.0.1java.xml.crypto@10.0.1java.xml.ws@10.0.1java.xml.ws.annotation@10.0.1javafx.base@10.0.1javafx.controls@10.0.1javafx.deploy@10.0.1javafx.fxml@10.0.1javafx.graphics@10.0.1javafx.media@10.0.1javafx.swing@10.0.1javafx.web@10.0.1jdk.accessibility@10.0.1jdk.aot@10.0.1jdk.attach@10.0.1jdk.charsets@10.0.1jdk.compiler@10.0.1jdk.crypto.cryptoki@10.0.1jdk.crypto.ec@10.0.1jdk.deploy@10.0.1jdk.deploy.controlpanel@10.0.1jdk.dynalink@10.0.1jdk.editpad@10.0.1jdk.hotspot.agent@10.0.1jdk.httpserver@10.0.1jdk.incubator.httpclient@10.0.1jdk.internal.ed@10.0.1jdk.internal.jvmstat@10.0.1jdk.internal.le@10.0.1jdk.internal.opt@10.0.1jdk.internal.vm.ci@10.0.1jdk.internal.vm.compiler@10.0.1jdk.internal.vm.compiler.management@10.0.1jdk.jartool@10.0.1jdk.javadoc@10.0.1jdk.javaws@10.0.1jdk.jcmd@10.0.1jdk.jconsole@10.0.1jdk.jdeps@10.0.1jdk.jdi@10.0.1jdk.jdwp.agent@10.0.1jdk.jfr@10.0.1jdk.jlink@10.0.1jdk.jshell@10.0.1jdk.jsobject@10.0.1jdk.jstatd@10.0.1jdk.localedata@10.0.1jdk.management@10.0.1jdk.management.agent@10.0.1jdk.management.cmm@10.0.1jdk.management.jfr@10.0.1jdk.management.resource@10.0.1jdk.naming.dns@10.0.1jdk.naming.rmi@10.0.1jdk.net@10.0.1jdk.pack@10.0.1jdk.packager@10.0.1jdk.packager.services@10.0.1jdk.plugin@10.0.1jdk.plugin.server@10.0.1jdk.rmic@10.0.1jdk.scripting.nashorn@10.0.1jdk.scripting.nashorn.shell@10.0.1jdk.sctp@10.0.1jdk.security.auth@10.0.1jdk.security.jgss@10.0.1jdk.snmp@10.0.1jdk.unsupported@10.0.1jdk.xml.bind@10.0.1jdk.xml.dom@10.0.1jdk.xml.ws@10.0.1jdk.zipfs@10.0.1oracle.desktop@10.0.1oracle.net@10.0.1\n模块描述符我们先从一个很简单的模块java.prefs开始1234567module java.prefs &#123;\trequires java.xml;\texports java.util.prefs;\tuses java.util.prefs.PreferencesFactory;&#125;\nRequiresrequires表示一个依赖关系，表明java.prefs依赖于java.xml，使用了java.xml模块中的代码块。(类似于Java的Import语句或者Maven的POM里的Dependency结构)\nExports强封装性是模块的默认特性，只有使用Exports关键字显式的导出一个包时，才可以从其他Requires了此模块的模块中访问这个包。一个模块中没有导出的包则不可以被别的模块所访问，即使他们之间存在依赖关系。（类似于Java中的Public关键字，但是是模块级别的）\nUsesUses子句告知ServiceLoader该模块想要消费PreferencesFactory的实现，然后ServiceLoader使PreferencesFactory的实例可以用于该模块。\n可访问性传统的访问修饰符及其影响范围：| 访问修饰符        | 类           | 包           | 子类           | 无限制           || ————- |:————-:| :————-:| :————-:| :————-:|| public      | √ | √ | √ | √ || protected      | √ | √ | √ |   || -(default)      | √ | √ |   |   || private      | √ |   |   |   |那么对于模块来说，传统的可访问性的规则还是否准确呢？假设有两个模块M1和M2，M1依赖了M2，那么M1是否可以访问M2中的类型呢？\n\nM1是否可以读取M2？\n如果可以，M2导出包中的类型是否可以访问？首先，基于模块的强封装性和依赖关系，模块只能访问所依赖的模块被导出的包中的类型。其次，对于所依赖的模块被导出的包中的类型，依然需要遵循传统的可访问性规则。再而，在传统的可访问性规则下，有一个有趣的方法setAccessible，通过调用setAccessible(true)获取任何元素的访问权限，但是在模块之间，这个方法的行为会不一致，例如在M1中试图使用setAccessible(true)获取M2中某个非导出包的类型的访问权限时，会得到报错（可以使用--permit-illegal-access选项屏蔽掉这种校验）。因此，在模块下，setAccessible(true)默认不会破坏这种封装性。隐式可读性在Maven体系里，如果一个A依赖了B，B依赖了C，在A中可以像使用自己的代码一样使用C中的代码，这就是依赖的传递性。但是在Java的模块世界里，可读性是默认是不可传递的，即使M1依赖了M2，M2依赖了M3，在M1中还是无法访问M3中的导出包中的类型。对于某些时候，M1中确实需要使用M3中的某些类型，以java.sql模块举例，假设M1使用了java.sql模块中的java.sql.Driver类中的方法public Logger getParentLogger() throws SQLFeatureNotSupportedException;，其中Logger类的定义是来自于java.sql模块所依赖的java.logging模块。如果M1没有依赖java.logging，则无法声明Logger类，也就无法获取到getParentLogger方法的返回值。当然M1是可以直接依赖java.logging模块的，但是这种情况Java早已意识到了，因此可以使用这样的方法定义java.sql模块：12345678910module java.sql &#123;\trequires transitive java.logging;\trequires transitive java.xml;\texports java.sql;\texports javax.sql;\texports javax.transaction.xa;\tuses java.sql.Driver;&#125;\n\n\nTransitiveRequires后面的Transitive关键字稍微改变了Requires的语义，Transitive关键字建立了一种隐式的可读性，使得可读性具备了传递性。以java.sql举例，在模块的定义中定义了java.logging的隐式可读性依赖，则所有依赖了java.sql的模块，都好像直接依赖了java.logging模块一样，可以访问java.logging导出包中的类型。\n限制导出以java.xml模块举例：1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253module java.xml &#123;\texports javax.xml;\texports javax.xml.catalog;\texports javax.xml.datatype;\texports javax.xml.namespace;\texports javax.xml.parsers;\texports javax.xml.stream;\texports javax.xml.stream.events;\texports javax.xml.stream.util;\texports javax.xml.transform;\texports javax.xml.transform.dom;\texports javax.xml.transform.sax;\texports javax.xml.transform.stax;\texports javax.xml.transform.stream;\texports javax.xml.validation;\texports javax.xml.xpath;\texports org.w3c.dom;\texports org.w3c.dom.bootstrap;\texports org.w3c.dom.events;\texports org.w3c.dom.ls;\texports org.w3c.dom.ranges;\texports org.w3c.dom.traversal;\texports org.w3c.dom.views;\texports org.xml.sax;\texports org.xml.sax.ext;\texports org.xml.sax.helpers;\texports com.sun.org.apache.xml.internal.dtm to\t\tjava.xml.crypto;\texports com.sun.org.apache.xml.internal.utils to\t\tjava.xml.crypto;\texports com.sun.org.apache.xpath.internal to\t\tjava.xml.crypto;\texports com.sun.org.apache.xpath.internal.compiler to\t\tjava.xml.crypto;\texports com.sun.org.apache.xpath.internal.functions to\t\tjava.xml.crypto;\texports com.sun.org.apache.xpath.internal.objects to\t\tjava.xml.crypto;\texports com.sun.org.apache.xpath.internal.res to\t\tjava.xml.crypto;\tuses javax.xml.datatype.DatatypeFactory;\tuses javax.xml.parsers.DocumentBuilderFactory;\tuses javax.xml.parsers.SAXParserFactory;\tuses javax.xml.stream.XMLEventFactory;\tuses javax.xml.stream.XMLInputFactory;\tuses javax.xml.stream.XMLOutputFactory;\tuses javax.xml.transform.TransformerFactory;\tuses javax.xml.validation.SchemaFactory;\tuses javax.xml.xpath.XPathFactory;\tuses org.xml.sax.XMLReader;&#125;\n看到中间一段exports…to…语句，与普通的exports语句不同的是，exports语句导出的包能被所有依赖于这个模块的模块所访问，但是如果是exports…to…语句，exports语句导出的包只能被to后面的模块所访问，例如exports com.sun.org.apache.xml.internal.dtm to java.xml.crypto，com.sun.org.apache.xml.internal.dtm导出包的内容只能被java.xml.crypto模块访问。【限制导出出现的理由是因为一些遗留代码的问题，而且使用限制导出也破坏了API的生产者和使用者之间的解耦，因为使用者模块名成为了提供者模块描述符的一部分。】\n在不使用模块的情况下使用模块化JDK在JDK9出现之后，如何兼容原有的非模块化的代码呢？在JDK9之后，所有在模块之外编译和加载的代码最终都在未命名模块(unnamed module)中，在这个特殊的未命名模块中，可以读取所有的其他的模块(java.se为根模块)，也就是说，未命名模块依赖了所有的模块。通过未命名模块，尚未模块化的代码可以继续在JDK9上运行。\n","dateCreated":"2018-07-29T05:53:20+08:00","dateModified":"2018-07-29T05:57:56+08:00","datePublished":"2018-07-29T05:53:20+08:00","description":"如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。","headline":"Java9 Modularity - Chapter 2 笔记-模块和模块化JDK","image":["http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale.title.wide"],"mainEntityOfPage":{"@type":"WebPage","@id":"http://ml3426.oschina.io/Study/java9-modularity-study-1.html"},"publisher":{"@type":"Organization","name":"ML3426","sameAs":["https://github.com/ML3426","https://weibo.com/ML3426"],"image":"http://oin1tuauu.bkt.clouddn.com/avatar.jpg","logo":{"@type":"ImageObject","url":"http://oin1tuauu.bkt.clouddn.com/avatar.jpg"}},"url":"http://ml3426.oschina.io/Study/java9-modularity-study-1.html","keywords":"Java, Java Modularity","thumbnailUrl":"http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale.title.wide"}</script>
    <meta name="description" content="如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。">
<meta name="keywords" content="Java,Java Modularity">
<meta property="og:type" content="blog">
<meta property="og:title" content="Java9 Modularity - Chapter 2 笔记-模块和模块化JDK">
<meta property="og:url" content="http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
<meta property="og:site_name" content="ML3426&#39;s Lair">
<meta property="og:description" content="如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。">
<meta property="og:locale" content="zh-cn">
<meta property="og:image" content="http://oin1tuauu.bkt.clouddn.com/ffwz4.jpg">
<meta property="og:updated_time" content="2018-07-28T21:57:56.336Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Java9 Modularity - Chapter 2 笔记-模块和模块化JDK">
<meta name="twitter:description" content="如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。">
<meta name="twitter:image" content="http://oin1tuauu.bkt.clouddn.com/ffwz4.jpg">
    
    
        
    
    
        <meta property="og:image" content="http://oin1tuauu.bkt.clouddn.com/avatar.jpg"/>
    
    
        <meta property="og:image" content="http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale.title.wide"/>
        <meta class="swiftype" name="image" data-type="enum" content="http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale.title.wide" />
    
    
    
    <!--STYLES-->
    <link rel="stylesheet" href="/assets/css/style-3frockyt2j28isvdztjchy5nhkz8tjki9ermufc1ckptmvjdftux94m2ahub.min.css">
    <!--STYLES END-->
    

    
    <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?7a67e9c867634890c1425150399ba634";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
    </script>

    <script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
</head>

    <body>
        <div id="blog">
            <!-- Define author's picture -->


<header id="header" data-behavior="5">
    <i id="btn-open-sidebar" class="fa fa-lg fa-bars"></i>
    <div class="header-title">
        <a class="header-title-link" href="/ ">ML3426&#39;s Lair</a>
    </div>
    
        
            <a  class="header-right-icon "
                href="#about">
        
        
            <i class="fa fa-lg fa-http://oin1tuauu.bkt.clouddn.com/avatar.jpg"></i>
        
        </a>
    
</header>

            <!-- Define author's picture -->



        
    

<nav id="sidebar" data-behavior="5">
    <div class="sidebar-container">
        
            <div class="sidebar-profile">
                <a href="/#about">
                    <img class="sidebar-profile-picture" src="http://oin1tuauu.bkt.clouddn.com/avatar.jpg" alt="作者的图片"/>
                </a>
                <h4 class="sidebar-profile-name">ML3426</h4>
                
                    <h5 class="sidebar-profile-bio"><p>author.bio</p>
</h5>
                
            </div>
        
        
            <ul class="sidebar-buttons">
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="/ "
                            
                            title="首页"
                        >
                    
                        <i class="sidebar-button-icon fa fa-home" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">首页</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="/all-categories"
                            
                            title="分类"
                        >
                    
                        <i class="sidebar-button-icon fa fa-bookmark" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">分类</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="/all-tags"
                            
                            title="标签"
                        >
                    
                        <i class="sidebar-button-icon fa fa-tags" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">标签</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="/all-archives"
                            
                            title="归档"
                        >
                    
                        <i class="sidebar-button-icon fa fa-archive" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">归档</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link open-algolia-search"
                             href="#search"
                            
                            title="搜索"
                        >
                    
                        <i class="sidebar-button-icon fa fa-search" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">搜索</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="#about"
                            
                            title="关于"
                        >
                    
                        <i class="sidebar-button-icon fa fa-question" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">关于</span>
                    </a>
            </li>
            
        </ul>
        
            <ul class="sidebar-buttons">
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link " href="https://github.com/ML3426" target="_blank" rel="noopener" title="同性社区">
                    
                        <i class="sidebar-button-icon fab fa-github" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">同性社区</span>
                    </a>
            </li>
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link " href="https://weibo.com/ML3426" target="_blank" rel="noopener" title="微博">
                    
                        <i class="sidebar-button-icon fab fa-weibo" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">微博</span>
                    </a>
            </li>
            
        </ul>
        
            <ul class="sidebar-buttons">
            
                <li class="sidebar-button">
                    
                        <a  class="sidebar-button-link "
                             href="/atom.xml"
                            
                            title="RSS"
                        >
                    
                        <i class="sidebar-button-icon fa fa-rss" aria-hidden="true"></i>
                        <span class="sidebar-button-desc">RSS</span>
                    </a>
            </li>
            
        </ul>
        
    </div>
</nav>

            
            <div id="main" data-behavior="5"
                 class="
                        hasCoverMetaIn
                        ">
                
<article class="post">
    
    
        <div class="post-header main-content-wrap text-center">
    
        <h1 class="post-title">
            Java9 Modularity - Chapter 2 笔记-模块和模块化JDK
        </h1>
    
    
        <div class="post-meta">
    <time datetime="2018-07-29T05:53:20+08:00">
	
		    7月 29, 2018
    	
    </time>
    
        <span>发布在 </span>
        
    <a class="category-link" href="/categories/Study/">Study</a>


    
</div>

    
</div>

    
    <div class="post-content markdown">
        <div class="main-content-wrap">
            <p>如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。<br><a id="more"></a><br><img src="http://oin1tuauu.bkt.clouddn.com/ffwz4.jpg" alt=""></p>
<h2 id="模块化和模块化JDK"><a href="#模块化和模块化JDK" class="headerlink" title="模块化和模块化JDK"></a>模块化和模块化JDK</h2><p>图中还显示了这些平台模块的自己以及依赖关系，这些边显示了模块之间的单项依赖关系。并且Java的模块系统不允许模块之间存在编译时循环依赖，因此图中所有箭头都是朝下的，没有循环。<br>通过运行<code>java --list-modules</code>可以获取平台模块的完整列表，在我的机器（Java 10.0.1）上运行的结果为：<br><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br></pre></td><td class="code"><pre><span class="line">ml3426@ML3426: java --list-modules</span><br><span class="line">java.activation@10.0.1</span><br><span class="line">java.base@10.0.1</span><br><span class="line">java.compiler@10.0.1</span><br><span class="line">java.corba@10.0.1</span><br><span class="line">java.datatransfer@10.0.1</span><br><span class="line">java.desktop@10.0.1</span><br><span class="line">java.instrument@10.0.1</span><br><span class="line">java.jnlp@10.0.1</span><br><span class="line">java.logging@10.0.1</span><br><span class="line">java.management@10.0.1</span><br><span class="line">java.management.rmi@10.0.1</span><br><span class="line">java.naming@10.0.1</span><br><span class="line">java.prefs@10.0.1</span><br><span class="line">java.rmi@10.0.1</span><br><span class="line">java.scripting@10.0.1</span><br><span class="line">java.se@10.0.1</span><br><span class="line">java.se.ee@10.0.1</span><br><span class="line">java.security.jgss@10.0.1</span><br><span class="line">java.security.sasl@10.0.1</span><br><span class="line">java.smartcardio@10.0.1</span><br><span class="line">java.sql@10.0.1</span><br><span class="line">java.sql.rowset@10.0.1</span><br><span class="line">java.transaction@10.0.1</span><br><span class="line">java.xml@10.0.1</span><br><span class="line">java.xml.bind@10.0.1</span><br><span class="line">java.xml.crypto@10.0.1</span><br><span class="line">java.xml.ws@10.0.1</span><br><span class="line">java.xml.ws.annotation@10.0.1</span><br><span class="line">javafx.base@10.0.1</span><br><span class="line">javafx.controls@10.0.1</span><br><span class="line">javafx.deploy@10.0.1</span><br><span class="line">javafx.fxml@10.0.1</span><br><span class="line">javafx.graphics@10.0.1</span><br><span class="line">javafx.media@10.0.1</span><br><span class="line">javafx.swing@10.0.1</span><br><span class="line">javafx.web@10.0.1</span><br><span class="line">jdk.accessibility@10.0.1</span><br><span class="line">jdk.aot@10.0.1</span><br><span class="line">jdk.attach@10.0.1</span><br><span class="line">jdk.charsets@10.0.1</span><br><span class="line">jdk.compiler@10.0.1</span><br><span class="line">jdk.crypto.cryptoki@10.0.1</span><br><span class="line">jdk.crypto.ec@10.0.1</span><br><span class="line">jdk.deploy@10.0.1</span><br><span class="line">jdk.deploy.controlpanel@10.0.1</span><br><span class="line">jdk.dynalink@10.0.1</span><br><span class="line">jdk.editpad@10.0.1</span><br><span class="line">jdk.hotspot.agent@10.0.1</span><br><span class="line">jdk.httpserver@10.0.1</span><br><span class="line">jdk.incubator.httpclient@10.0.1</span><br><span class="line">jdk.internal.ed@10.0.1</span><br><span class="line">jdk.internal.jvmstat@10.0.1</span><br><span class="line">jdk.internal.le@10.0.1</span><br><span class="line">jdk.internal.opt@10.0.1</span><br><span class="line">jdk.internal.vm.ci@10.0.1</span><br><span class="line">jdk.internal.vm.compiler@10.0.1</span><br><span class="line">jdk.internal.vm.compiler.management@10.0.1</span><br><span class="line">jdk.jartool@10.0.1</span><br><span class="line">jdk.javadoc@10.0.1</span><br><span class="line">jdk.javaws@10.0.1</span><br><span class="line">jdk.jcmd@10.0.1</span><br><span class="line">jdk.jconsole@10.0.1</span><br><span class="line">jdk.jdeps@10.0.1</span><br><span class="line">jdk.jdi@10.0.1</span><br><span class="line">jdk.jdwp.agent@10.0.1</span><br><span class="line">jdk.jfr@10.0.1</span><br><span class="line">jdk.jlink@10.0.1</span><br><span class="line">jdk.jshell@10.0.1</span><br><span class="line">jdk.jsobject@10.0.1</span><br><span class="line">jdk.jstatd@10.0.1</span><br><span class="line">jdk.localedata@10.0.1</span><br><span class="line">jdk.management@10.0.1</span><br><span class="line">jdk.management.agent@10.0.1</span><br><span class="line">jdk.management.cmm@10.0.1</span><br><span class="line">jdk.management.jfr@10.0.1</span><br><span class="line">jdk.management.resource@10.0.1</span><br><span class="line">jdk.naming.dns@10.0.1</span><br><span class="line">jdk.naming.rmi@10.0.1</span><br><span class="line">jdk.net@10.0.1</span><br><span class="line">jdk.pack@10.0.1</span><br><span class="line">jdk.packager@10.0.1</span><br><span class="line">jdk.packager.services@10.0.1</span><br><span class="line">jdk.plugin@10.0.1</span><br><span class="line">jdk.plugin.server@10.0.1</span><br><span class="line">jdk.rmic@10.0.1</span><br><span class="line">jdk.scripting.nashorn@10.0.1</span><br><span class="line">jdk.scripting.nashorn.shell@10.0.1</span><br><span class="line">jdk.sctp@10.0.1</span><br><span class="line">jdk.security.auth@10.0.1</span><br><span class="line">jdk.security.jgss@10.0.1</span><br><span class="line">jdk.snmp@10.0.1</span><br><span class="line">jdk.unsupported@10.0.1</span><br><span class="line">jdk.xml.bind@10.0.1</span><br><span class="line">jdk.xml.dom@10.0.1</span><br><span class="line">jdk.xml.ws@10.0.1</span><br><span class="line">jdk.zipfs@10.0.1</span><br><span class="line">oracle.desktop@10.0.1</span><br><span class="line">oracle.net@10.0.1</span><br></pre></td></tr></table></figure></p>
<h2 id="模块描述符"><a href="#模块描述符" class="headerlink" title="模块描述符"></a>模块描述符</h2><p>我们先从一个很简单的模块java.prefs开始<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">module</span> java.prefs &#123;</span><br><span class="line">	<span class="keyword">requires</span> java.xml;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">exports</span> java.util.prefs;</span><br><span class="line"></span><br><span class="line">	uses java.util.prefs.PreferencesFactory;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h3 id="Requires"><a href="#Requires" class="headerlink" title="Requires"></a>Requires</h3><p>requires表示一个依赖关系，表明java.prefs依赖于java.xml，使用了java.xml模块中的代码块。(类似于Java的Import语句或者Maven的POM里的Dependency结构)</p>
<h3 id="Exports"><a href="#Exports" class="headerlink" title="Exports"></a>Exports</h3><p>强封装性是模块的默认特性，只有使用Exports关键字显式的导出一个包时，才可以从其他Requires了此模块的模块中访问这个包。一个模块中没有导出的包则不可以被别的模块所访问，即使他们之间存在依赖关系。（类似于Java中的Public关键字，但是是模块级别的）</p>
<h3 id="Uses"><a href="#Uses" class="headerlink" title="Uses"></a>Uses</h3><p>Uses子句告知ServiceLoader该模块想要消费PreferencesFactory的实现，然后ServiceLoader使PreferencesFactory的实例可以用于该模块。</p>
<h2 id="可访问性"><a href="#可访问性" class="headerlink" title="可访问性"></a>可访问性</h2><p>传统的访问修饰符及其影响范围：<br>| 访问修饰符        | 类           | 包           | 子类           | 无限制           |<br>| ————- |:————-:| :————-:| :————-:| :————-:|<br>| public      | √ | √ | √ | √ |<br>| protected      | √ | √ | √ |   |<br>| -(default)      | √ | √ |   |   |<br>| private      | √ |   |   |   |<br>那么对于模块来说，传统的可访问性的规则还是否准确呢？假设有两个模块M1和M2，M1依赖了M2，那么M1是否可以访问M2中的类型呢？</p>
<ol>
<li>M1是否可以读取M2？</li>
<li>如果可以，M2导出包中的类型是否可以访问？<br>首先，基于模块的强封装性和依赖关系，模块只能访问所依赖的模块被导出的包中的类型。<br>其次，对于所依赖的模块被导出的包中的类型，依然需要遵循传统的可访问性规则。<br>再而，在传统的可访问性规则下，有一个有趣的方法<code>setAccessible</code>，通过调用<code>setAccessible(true)</code>获取任何元素的访问权限，但是在模块之间，这个方法的行为会不一致，例如在M1中试图使用<code>setAccessible(true)</code>获取M2中某个非导出包的类型的访问权限时，会得到报错（可以使用<code>--permit-illegal-access</code>选项屏蔽掉这种校验）。因此，在模块下，<code>setAccessible(true)</code>默认不会破坏这种封装性。<h2 id="隐式可读性"><a href="#隐式可读性" class="headerlink" title="隐式可读性"></a>隐式可读性</h2>在Maven体系里，如果一个A依赖了B，B依赖了C，在A中可以像使用自己的代码一样使用C中的代码，这就是依赖的<strong>传递性</strong>。<br>但是在Java的模块世界里，可读性是默认是不可传递的，即使M1依赖了M2，M2依赖了M3，在M1中还是无法访问M3中的导出包中的类型。<br>对于某些时候，M1中确实需要使用M3中的某些类型，以<code>java.sql</code>模块举例，假设M1使用了<code>java.sql</code>模块中的<code>java.sql.Driver</code>类中的方法<code>public Logger getParentLogger() throws SQLFeatureNotSupportedException;</code>，其中<code>Logger</code>类的定义是来自于<code>java.sql</code>模块所依赖的<code>java.logging</code>模块。如果M1没有依赖<code>java.logging</code>，则无法声明<code>Logger</code>类，也就无法获取到<code>getParentLogger</code>方法的返回值。当然M1是可以直接依赖<code>java.logging</code>模块的，但是这种情况Java早已意识到了，因此可以使用这样的方法定义<code>java.sql</code>模块：<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">module</span> java.sql &#123;</span><br><span class="line">	<span class="keyword">requires</span> transitive java.logging;</span><br><span class="line">	<span class="keyword">requires</span> transitive java.xml;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">exports</span> java.sql;</span><br><span class="line">	<span class="keyword">exports</span> javax.sql;</span><br><span class="line">	<span class="keyword">exports</span> javax.transaction.xa;</span><br><span class="line"></span><br><span class="line">	uses java.sql.Driver;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h3 id="Transitive"><a href="#Transitive" class="headerlink" title="Transitive"></a>Transitive</h3><p>Requires后面的Transitive关键字稍微改变了Requires的语义，Transitive关键字建立了一种隐式的可读性，使得可读性具备了传递性。以<code>java.sql</code>举例，在模块的定义中定义了<code>java.logging</code>的隐式可读性依赖，则所有依赖了<code>java.sql</code>的模块，都好像直接依赖了<code>java.logging</code>模块一样，可以访问<code>java.logging</code>导出包中的类型。</p>
<h2 id="限制导出"><a href="#限制导出" class="headerlink" title="限制导出"></a>限制导出</h2><p>以<code>java.xml</code>模块举例：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">module</span> java.xml &#123;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.catalog;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.datatype;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.namespace;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.parsers;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.stream;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.stream.events;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.stream.util;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.transform;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.transform.dom;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.transform.sax;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.transform.stax;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.transform.stream;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.validation;</span><br><span class="line">	<span class="keyword">exports</span> javax.xml.xpath;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.bootstrap;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.events;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.ls;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.ranges;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.traversal;</span><br><span class="line">	<span class="keyword">exports</span> org.w3c.dom.views;</span><br><span class="line">	<span class="keyword">exports</span> org.xml.sax;</span><br><span class="line">	<span class="keyword">exports</span> org.xml.sax.ext;</span><br><span class="line">	<span class="keyword">exports</span> org.xml.sax.helpers;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xml.internal.dtm to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xml.internal.utils to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xpath.internal to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xpath.internal.compiler to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xpath.internal.functions to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xpath.internal.objects to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line">	<span class="keyword">exports</span> com.sun.org.apache.xpath.internal.res to</span><br><span class="line">		java.xml.crypto;</span><br><span class="line"></span><br><span class="line">	uses javax.xml.datatype.DatatypeFactory;</span><br><span class="line">	uses javax.xml.parsers.DocumentBuilderFactory;</span><br><span class="line">	uses javax.xml.parsers.SAXParserFactory;</span><br><span class="line">	uses javax.xml.stream.XMLEventFactory;</span><br><span class="line">	uses javax.xml.stream.XMLInputFactory;</span><br><span class="line">	uses javax.xml.stream.XMLOutputFactory;</span><br><span class="line">	uses javax.xml.transform.TransformerFactory;</span><br><span class="line">	uses javax.xml.validation.SchemaFactory;</span><br><span class="line">	uses javax.xml.xpath.XPathFactory;</span><br><span class="line">	uses org.xml.sax.XMLReader;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>看到中间一段<code>exports…to…</code>语句，与普通的exports语句不同的是，exports语句导出的包能被所有依赖于这个模块的模块所访问，但是如果是<code>exports…to…</code>语句，exports语句导出的包只能被to后面的模块所访问，例如<code>exports com.sun.org.apache.xml.internal.dtm to java.xml.crypto</code>，<code>com.sun.org.apache.xml.internal.dtm</code>导出包的内容只能被<code>java.xml.crypto</code>模块访问。<br>【限制导出出现的理由是因为一些遗留代码的问题，而且使用限制导出也破坏了API的生产者和使用者之间的解耦，因为使用者模块名成为了提供者模块描述符的一部分。】</p>
<h2 id="在不使用模块的情况下使用模块化JDK"><a href="#在不使用模块的情况下使用模块化JDK" class="headerlink" title="在不使用模块的情况下使用模块化JDK"></a>在不使用模块的情况下使用模块化JDK</h2><p>在JDK9出现之后，如何兼容原有的非模块化的代码呢？在JDK9之后，所有在模块之外编译和加载的代码最终都在未命名模块(unnamed module)中，在这个特殊的未命名模块中，可以读取所有的其他的模块(java.se为根模块)，也就是说，未命名模块依赖了所有的模块。通过未命名模块，尚未模块化的代码可以继续在JDK9上运行。</p>

            

        </div>
    </div>
    <div id="post-footer" class="post-footer main-content-wrap">
        
            <div class="post-footer-tags">
                <span class="text-color-light text-small">标签</span><br/>
                
    <a class="tag tag--primary tag--small t-link" href="/tags/Java/">Java</a> <a class="tag tag--primary tag--small t-link" href="/tags/Java-Modularity/">Java Modularity</a>

            </div>
        
        
            <div class="post-actions-wrap">
    <nav>
        <ul class="post-actions post-action-nav">
            <li class="post-action">
                
                    <a class="post-action-btn btn btn--disabled">
                
                    <i class="fa fa-angle-left" aria-hidden="true"></i>
                    <span class="hide-xs hide-sm text-small icon-ml">上一篇</span>
                </a>
            </li>
            <li class="post-action">
                
                    
                    <a class="post-action-btn btn btn--default tooltip--top" href="/Study/java9-modularity-study-0.html" data-tooltip="Java9 Modularity - Chapter 1 笔记-模块化概述" aria-label="下一篇: Java9 Modularity - Chapter 1 笔记-模块化概述">
                
                    <span class="hide-xs hide-sm text-small icon-mr">下一篇</span>
                    <i class="fa fa-angle-right" aria-hidden="true"></i>
                </a>
            </li>
        </ul>
    </nav>
    <ul class="post-actions post-action-share">
        <li class="post-action hide-lg hide-md hide-sm">
            <a class="post-action-btn btn btn--default btn-open-shareoptions" href="#btn-open-shareoptions" aria-label="Diesen Beitrag teilen">
                <i class="fa fa-share-alt" aria-hidden="true"></i>
            </a>
        </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://www.facebook.com/sharer/sharer.php?u=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Facebook">
                    <i class="fa fa-facebook-official" aria-hidden="true"></i>
                </a>
            </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://twitter.com/intent/tweet?text=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Twitter">
                    <i class="fa fa-twitter" aria-hidden="true"></i>
                </a>
            </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://plus.google.com/share?url=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Google+">
                    <i class="fa fa-google-plus" aria-hidden="true"></i>
                </a>
            </li>
        
        
            
                <li class="post-action">
                    <a class="post-action-btn btn btn--default" href="#gitment">
                         <i class="fa fa-comment-o"></i>
                    </a>
                </li>
            
        
        <li class="post-action">
            
                <a class="post-action-btn btn btn--default" href="#" aria-label="Nach oben">
            
                <i class="fa fa-list" aria-hidden="true"></i>
            </a>
        </li>
    </ul>
</div>


        
        
            
                <div id="gitment"></div>
            
        
    </div>
</article>



                <footer id="footer" class="main-content-wrap">
	<span id="busuanzi_container_site_uv">本站访客数<span id="busuanzi_value_site_uv"></span>次</span>
	<br/>
    <span class="copyrights">
        Copyrights &copy; 2018 ML3426. All Rights Reserved.
    </span>
</footer>

            </div>
            
                <div id="bottom-bar" class="post-bottom-bar" data-behavior="5">
                    <div class="post-actions-wrap">
    <nav>
        <ul class="post-actions post-action-nav">
            <li class="post-action">
                
                    <a class="post-action-btn btn btn--disabled">
                
                    <i class="fa fa-angle-left" aria-hidden="true"></i>
                    <span class="hide-xs hide-sm text-small icon-ml">上一篇</span>
                </a>
            </li>
            <li class="post-action">
                
                    
                    <a class="post-action-btn btn btn--default tooltip--top" href="/Study/java9-modularity-study-0.html" data-tooltip="Java9 Modularity - Chapter 1 笔记-模块化概述" aria-label="下一篇: Java9 Modularity - Chapter 1 笔记-模块化概述">
                
                    <span class="hide-xs hide-sm text-small icon-mr">下一篇</span>
                    <i class="fa fa-angle-right" aria-hidden="true"></i>
                </a>
            </li>
        </ul>
    </nav>
    <ul class="post-actions post-action-share">
        <li class="post-action hide-lg hide-md hide-sm">
            <a class="post-action-btn btn btn--default btn-open-shareoptions" href="#btn-open-shareoptions" aria-label="Diesen Beitrag teilen">
                <i class="fa fa-share-alt" aria-hidden="true"></i>
            </a>
        </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://www.facebook.com/sharer/sharer.php?u=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Facebook">
                    <i class="fa fa-facebook-official" aria-hidden="true"></i>
                </a>
            </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://twitter.com/intent/tweet?text=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Twitter">
                    <i class="fa fa-twitter" aria-hidden="true"></i>
                </a>
            </li>
        
            
            
            <li class="post-action hide-xs">
                <a class="post-action-btn btn btn--default" target="new" href="https://plus.google.com/share?url=http://ml3426.oschina.io/Study/java9-modularity-study-1.html" title="分享到 Google+">
                    <i class="fa fa-google-plus" aria-hidden="true"></i>
                </a>
            </li>
        
        
            
                <li class="post-action">
                    <a class="post-action-btn btn btn--default" href="#gitment">
                         <i class="fa fa-comment-o"></i>
                    </a>
                </li>
            
        
        <li class="post-action">
            
                <a class="post-action-btn btn btn--default" href="#" aria-label="Nach oben">
            
                <i class="fa fa-list" aria-hidden="true"></i>
            </a>
        </li>
    </ul>
</div>


                </div>
                <div id="share-options-bar" class="share-options-bar" data-behavior="5">
    <i id="btn-close-shareoptions" class="fa fa-close"></i>
    <ul class="share-options">
        
            
            
            <li class="share-option">
                <a class="share-option-btn" target="new" href="https://www.facebook.com/sharer/sharer.php?u=http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
                    <i class="fa fa-facebook-official" aria-hidden="true"></i><span>分享到 Facebook</span>
                </a>
            </li>
        
            
            
            <li class="share-option">
                <a class="share-option-btn" target="new" href="https://twitter.com/intent/tweet?text=http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
                    <i class="fa fa-twitter" aria-hidden="true"></i><span>分享到 Twitter</span>
                </a>
            </li>
        
            
            
            <li class="share-option">
                <a class="share-option-btn" target="new" href="https://plus.google.com/share?url=http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
                    <i class="fa fa-google-plus" aria-hidden="true"></i><span>分享到 Google+</span>
                </a>
            </li>
        
    </ul>
</div>

            
        </div>
        


    
        
    

<div id="about">
    <div id="about-card">
        <div id="about-btn-close">
            <i class="fa fa-remove"></i>
        </div>
        
            <img id="about-card-picture" src="http://oin1tuauu.bkt.clouddn.com/avatar.jpg" alt="作者的图片"/>
        
            <h4 id="about-card-name">ML3426</h4>
        
            <div id="about-card-bio"><p>author.bio</p>
</div>
        
        
            <div id="about-card-job">
                <i class="fa fa-briefcase"></i>
                <br/>
                <p>author.job</p>

            </div>
        
        
            <div id="about-card-location">
                <i class="fa fa-map-marker"></i>
                <br/>
                浙江杭州
            </div>
        
    </div>
</div>

        
            <div id="algolia-search-modal" class="modal-container">
    <div class="modal">
        <div class="modal-header">
            <span class="close-button"><i class="fa fa-close"></i></span>
            <a href="https://algolia.com" target="_blank" rel="noopener" class="searchby-algolia text-color-light link-unstyled">
                <span class="searchby-algolia-text text-color-light text-small">by</span>
                <img class="searchby-algolia-logo" src="https://www.algolia.com/static_assets/images/press/downloads/algolia-light.svg">
            </a>
            <i class="search-icon fa fa-search"></i>
            <form id="algolia-search-form">
                <input type="text" id="algolia-search-input" name="search"
                    class="form-control input--large search-input" placeholder="Search "
                    />
            </form>
        </div>
        <div class="modal-body">
            <div class="no-result text-color-light text-center">没有找到文章</div>
            <div class="results">
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Essay/from2016to2017.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/image/jpg/6763119437_5b978e75a7_o.jpg-scale140" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Essay/from2016to2017.html">
                            <h3 class="media-heading">我的2016，我的2017</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2017年1月12日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>随着舷窗外的空气由纯白色变成了淡淡的土黄色，飞机降落到了长沙黄花机场的跑道上，正式宣告着我的实习生活正式结束了，也宣告着我的2016年生活划上了一个句点。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Essay/jobhunt-exp.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/image/jpg/jobhunt_exp_title.jpg-scale140" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Essay/jobhunt-exp.html">
                            <h3 class="media-heading">求职之路经验分享</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2017年4月7日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>到了大三、大四的时候，所有人都面临着大学生活即将结束，接下来该如何前进的抉择。关于这个问题，出路无非是工作，留学，读研，创业这么几种。由于我是工作党，这里就跟大家分享一下我自己的求职经验和感想。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java-asm-study-0.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/c10e3.jpg-scale140" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java-asm-study-0.html">
                            <h3 class="media-heading">ASM学习笔记0 - Hello World</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2018年7月12日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>最近在工作中，遇到了一个可能大部分Java开发人员都遇到过的痛点，试用了几种其他的工具类框架，发现都有不是很满意的地方，因此就有了一个主意来自己写一个。但是在我的预想中，做这个工具需要和CGLib以及ASM打交道比较多，所以就打算从ASM以及CGLib开始学起，但是要学ASM，先学好JVM和字节码是前提。一边学习我也会一边产出我自己的学习笔记希望能够帮助到更多的人。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java-asm-study-1.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/c10e3.jpg-scale140" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java-asm-study-1.html">
                            <h3 class="media-heading">ASM学习笔记1 - JNI字段描述符</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2018年7月12日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>在之前的笔记中，我们看到了一段根据一个Java的HelloWorld程序反编译出来的字节码，在字节码的comment部分，我们看到了一些诸如<strong>[Ljava/lang/String</strong>或者<strong>()V</strong>之类的代码段，这样的代码段看起来与一般的类全路径有点像，但也有些不同。这样的写法，叫做JNI字段描述符。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java9-modularity-study-0.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale140" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java9-modularity-study-0.html">
                            <h3 class="media-heading">Java9 Modularity - Chapter 1 笔记-模块化概述</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2018年7月12日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>对于一个大型系统，系统的复杂度可能会超过我们理解和有效开发的能力范围。如果应用缺乏结构性，可能在之后的开发运维过程中付出巨大的代价。而模块化，则是用来管理和减少这种复杂性的技术之一。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
                <div class="media">
                    
                    <div class="media-left">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
                            <img class="media-image" src="http://oin1tuauu.bkt.clouddn.com/ek6c0.jpg-scale.title.wide" width="90" height="90"/>
                        </a>
                    </div>
                    
                    <div class="media-body">
                        <a class="link-unstyled" href="http://ml3426.oschina.io/Study/java9-modularity-study-1.html">
                            <h3 class="media-heading">Java9 Modularity - Chapter 2 笔记-模块和模块化JDK</h3>
                        </a>
                        <span class="media-meta">
                            <span class="media-date text-small">
                                
                                    2018年7月29日
                                
                            </span>
                        </span>
                        <div class="media-content hide-xs font-merryweather"><p>如图，目前在JDK9中定义了90多个平台模块（图中只画出了部分），JDK9就是由这90多个模块构成，而不是一个整体库。<br></div>
                    </div>
                    <div style="clear:both;"></div>
                    <hr>
                </div>
                
            </div>
        </div>
        <div class="modal-footer">
            <p class="results-count text-medium"
                data-message-zero="没有找到文章"
                data-message-one="找到 1 篇文章"
                data-message-other="找到 {n} 篇文章">
                找到 6 篇文章
            </p>
        </div>
    </div>
</div>

        
        
<div id="cover" style="background-image:url('/assets/images/cover.jpg');"></div>
        <!--SCRIPTS-->
<script src="/assets/js/script-xzfezjobyekpxrjktw5tz6muvzqfsbmo5n6atk3p5om9ulfptldi3p7cyqd8.min.js"></script>
<!--SCRIPTS END-->

    
        <script type="text/javascript">
            (function() {
                function render() {
                    new Gitment({
                        id: 'Sun Jul 29 2018 05:53:20 GMT+0800',
                        owner: 'FML3426',
                        repo: 'blog_gitcomment',
                        oauth: {
                            client_id: '0f00579407bcf3bb59ee',
                            client_secret: '491d910dd9e560666051f860569f53f1a737e3c9',
                        }
                    }).render('gitment');
                }
                var gc = document.createElement('script');
                gc.type = 'text/javascript';
                gc.src = '//imsun.github.io/gitment/dist/gitment.browser.js';
                gc.charset = 'UTF-8';
                gc.onload = render;
                gc.async = true;
                document.querySelector('body').appendChild(gc);
                var gcs = document.createElement('link');
                gcs.href = '//imsun.github.io/gitment/style/default.css';
                gcs.type = 'text/css';
                gcs.rel = 'stylesheet';
                gcs.media = 'screen,print';
                document.querySelector('head').appendChild(gcs);
            })();
	    </script>
    


    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment-with-locales.min.js"></script>
    <script src="//cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
    <script>
        var algoliaClient = algoliasearch('8QTBISJQTD', 'e228775761b8c86b2158a77831bc74f5');
        var algoliaIndex = algoliaClient.initIndex('osc_blog_index');
    </script>


    </body>
</html>
